<template>
  <div>
     <a-alert class="card"  message="※博士分数线设置和按学科专业码设置同时设置时，以最后设置的分数线为准，外语分数线设置为单项匹配。不需要设置分数线的项目，分数线请设置为0" banner />
    <a-card>
      
  

      <a-tabs defaultActiveKey="1">
      <a-tab-pane tab="学术学位分数线设置" key="1" forceRender>
        <stu-info ref="stuInfo"></stu-info>
      </a-tab-pane>
      <a-tab-pane tab="专业学位分数线设置" key="2" forceRender>
        <scoreInfo ref="scoreInfo"/>
      </a-tab-pane>
    </a-tabs>

     
    </a-card>

  </div>
</template>
<script>
import { mapState } from 'vuex'
const selectArr = ['TYPE0126']
import stuInfo from './components/code'
import scoreInfo from './components/codeStu'
export default {
  data () {
    return {
      selectMenu: {},
      loading: false,
      imageUrl: '',
      loadingBtn: false,
      xkmc:''
    }
  },
      components: {
    stuInfo,
    scoreInfo
  },
  beforeCreate () {
    this.form = this.$form.createForm(this)
  },
  computed: {
   ...mapState({
      systemInfo: state => state.app.systemInfo,
      TYPE0126: state => state.app['TYPE0126'] // 年级
    })
  },
  created () {
    selectArr.forEach(v => {
      this.$store.dispatch('app/setDictionary', v)
    })
    this.initSelectMenu()
  },
  methods: {
    initSelectMenu () {
      let allRequest = [
        this.$api.base.collegeAll(),
        this.$api.base.areaList()
      ]
      Promise.all(allRequest).then(res => {
        this.selectMenu = {
          yx: res[0].data
        }
      })
       this.$api.base.getSchoolYear().then(res=>{
        this.form.setFieldsValue({'zsnj':res.data.doctoralAdmissionYear})
      })
    },
    handleSearch () {
      console.log(this.form.getFieldsValue().xkzym);
      
      
      if(this.form.getFieldsValue().xkzym=='' || typeof(this.form.getFieldsValue()).xkzym == "undefined"){
        this.xkmc='';
      }else{
           let parms={'xkzym':this.form.getFieldsValue().xkzym}
         this.$api.base.getMajor(parms).then(res=>{
           if(res.data){
             this.xkmc=res.data.xkmc;
           }
         })
      }
    },
    handleSubmit () {
       this.form.validateFields((err, values) => {
          if (err) {
            this.$message.error('请输入必填项')
            return
          }
      this.form.getFieldsValue().xkmc=this.xkmc;
      var params = Object.assign({xkmc:this.xkmc},this.form.getFieldsValue())
      console.log(this.form.getFieldsValue());
        this.$api.doctorRecruit.specialtySave(params).then(res => {
      	 this.$message.success(res.msg)
      	// this.$emit('success')
      }).finally(() => {
      	this.loadingBtn = false
        this.form.setFieldsValue({'xkzym':'','wytlfsx':'','wybsfsx':'','wykyfsx':'','wyzffsx':'','ywkyfsx':'','ywkefsx':'','ywksfsx':'','ywkzcjfsx':''})
        this.xkmc='';
      })
    })
    }
  }
}
</script>
